VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "GUI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Boolean) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long

Private Const MF_BYPOSITION = &H400&
Private Const MF_REMOVE = &H1000&

Dim XDisabled As Boolean

Public Sub OpenWindow()
frmTemplate.Show
DisableClose frmTemplate
XDisabled = True
End Sub

Public Sub SetWindowTitle(strTitle As String)
frmTemplate.Caption = strTitle
End Sub

Public Sub SetWindowColor(bytColor As Byte)
frmTemplate.BackColor = QBColor(bytColor)
End Sub

Public Sub SetWindowIcon(strPath As String)
If strPath = vbNullString Then
    Dim imgNull As Image
    frmTemplate.Icon = imgNull
Else
    frmTemplate.Icon = LoadPicture(strPath)
End If
End Sub

Public Sub SetWindowLocation(intXPos As Integer, intYPos As Integer)
frmTemplate.Left = intXPos
frmTemplate.Top = intYPos
End Sub

Public Sub SetWindowSize(intX As Integer, intY As Integer)
frmTemplate.Width = intX * Screen.TwipsPerPixelX
frmTemplate.Height = intY * Screen.TwipsPerPixelY
End Sub

Public Sub CenterWindow()
frmTemplate.Move (Screen.Width - frmTemplate.Width) / 2, (Screen.Height - frmTemplate.Height) / 2
End Sub

Public Sub CloseWindow()
Unload frmTemplate
End Sub

Public Function IsPushed(strType As String, btnNumber As Byte) As Boolean
If btnNumber = frmTemplate.pushedNo And strType = frmTemplate.pushedType Then
    IsPushed = True
    frmTemplate.pushedNo = -1
Else
    IsPushed = False
End If
End Function

Public Function IsTextChanged(txtNumber As Byte) As Boolean
If txtNumber = frmTemplate.changedNo Then
    IsTextChanged = True
    frmTemplate.changedNo = -1
Else
    IsTextChanged = False
End If
End Function

Public Function IsChecked(chkNumber As Byte) As Boolean
IsChecked = CBool(frmTemplate.chk(chkNumber).Value)
End Function

Public Function IsEntered(txtNumber As Byte) As Boolean
If txtNumber = frmTemplate.enteredNo Then
    IsEntered = True
    frmTemplate.enteredNo = -1
Else
    IsEntered = False
End If
End Function

Public Function XIsPushed() As Boolean
If XDisabled Then
    DisableClose frmTemplate, False
    XDisabled = False
End If
If Not frmTemplate.Visible Then
    XIsPushed = True
Else
    XIsPushed = False
End If
End Function

Public Sub NewButton(btnNumber As Byte, btnCaption As String, X As Integer, Y As Integer)
Load frmTemplate.btn(btnNumber)
With frmTemplate.btn(btnNumber)
    .Caption = btnCaption
    .Left = X
    .Top = Y
    .Visible = True
End With
End Sub

Public Sub NewPicture(picNumber As Byte, picPath As String, X As Integer, Y As Integer)
Load frmTemplate.pic(picNumber)
With frmTemplate.pic(picNumber)
    .Left = X
    .Top = Y
    .Visible = True
End With
frmTemplate.pic(picNumber).Picture = LoadPicture(picPath)
End Sub

Public Sub NewTextBox(txtNumber As Byte, strText As String, X As Integer, Y As Integer, sizeX As Integer, sizeY As Integer)
Load frmTemplate.txt(txtNumber)
With frmTemplate.txt(txtNumber)
    .Left = X
    .Top = Y
    .Width = sizeX
    .Height = sizeY
    .Text = strText
    .Visible = True
End With
End Sub

Public Sub NewLabel(lblNumber As Byte, strText As String, X As Integer, Y As Integer)
Load frmTemplate.lbl(lblNumber)
With frmTemplate.lbl(lblNumber)
    .Left = X
    .Top = Y
    .Caption = strText
    .Visible = True
End With
End Sub

Public Sub NewCheckBox(chkNumber As Byte, strText As String, X As Integer, Y As Integer)
Load frmTemplate.chk(chkNumber)
With frmTemplate.chk(chkNumber)
    .Left = X
    .Top = Y
    .Caption = strText
    .Visible = True
End With
End Sub

Public Sub SetButtonLocation(btnNumber As Byte, btnX As Integer, btnY As Integer)
frmTemplate.btn(btnNumber).Left = btnX
frmTemplate.btn(btnNumber).Top = btnY
End Sub

Public Sub SetButtonSize(btnNumber As Byte, sizeX As Integer, sizeY As Integer)
frmTemplate.btn(btnNumber).Width = sizeX
frmTemplate.btn(btnNumber).Height = sizeY
End Sub

Public Sub SetButtonFont(btnNumber As Byte, strFont As String)
frmTemplate.btn(btnNumber).FontName = strFont
End Sub

Public Sub SetButtonFontSize(btnNumber As Byte, intSize As Integer)
frmTemplate.btn(btnNumber).FontSize = intSize
End Sub

Public Sub SetPictureLocation(picNumber As Byte, picX As Integer, picY As Integer)
frmTemplate.pic(picNumber).Left = picX
frmTemplate.pic(picNumber).Top = picY
End Sub

Public Sub SetPictureSize(picNumber As Byte, sizeX As Integer, sizeY As Integer)
frmTemplate.pic(picNumber).Width = sizeX
frmTemplate.pic(picNumber).Height = sizeY
End Sub

Public Sub SetPicture(picNumber As Byte, picPath As String)
frmTemplate.pic(picNumber).Picture = LoadPicture(picPath)
End Sub

Public Sub SetTextColor(txtNumber As Byte, txtBackColor As Byte, txtForeColor As Byte)
frmTemplate.txt(txtNumber).BackColor = QBColor(txtBackColor)
frmTemplate.txt(txtNumber).ForeColor = QBColor(txtForeColor)
End Sub

Public Sub SetTextLocation(txtNumber As Byte, txtX As Integer, txtY As Integer)
frmTemplate.txt(txtNumber).Left = txtX
frmTemplate.txt(txtNumber).Top = txtY
End Sub

Public Sub SetTextSize(txtNumber As Byte, sizeX As Integer, sizeY As Integer)
frmTemplate.txt(txtNumber).Width = sizeX
frmTemplate.txt(txtNumber).Height = sizeY
End Sub

Public Sub SetTextFont(txtNumber As Byte, strFont As String)
frmTemplate.txt(txtNumber).FontName = strFont
End Sub

Public Sub SetTextFontSize(txtNumber As Byte, intSize As Integer)
frmTemplate.txt(txtNumber).FontSize = intSize
End Sub

Public Sub SetTextMask(txtNumber As Byte, strMask As String)
frmTemplate.txt(txtNumber).PasswordChar = strMask
End Sub

Public Sub SetLabelColor(lblNumber As Byte, lblForeColor As Byte)
frmTemplate.lbl(lblNumber).ForeColor = QBColor(lblForeColor)
End Sub

Public Sub SetLabelLocation(lblNumber As Byte, lblX As Integer, lblY As Integer)
frmTemplate.lbl(lblNumber).Left = lblX
frmTemplate.lbl(lblNumber).Top = lblY
End Sub

Public Sub SetLabelSize(lblNumber As Byte, sizeX As Integer, sizeY As Integer)
frmTemplate.lbl(lblNumber).Width = sizeX
frmTemplate.lbl(lblNumber).Height = sizeY
End Sub

Public Sub SetLabelFont(lblNumber As Byte, strFont As String)
frmTemplate.lbl(lblNumber).FontName = strFont
End Sub

Public Sub SetLabelFontSize(lblNumber As Byte, intSize As Integer)
frmTemplate.lbl(lblNumber).FontSize = intSize
End Sub

Public Sub SetCheckBoxLocation(chkNumber As Byte, chkX As Integer, chkY As Integer)
frmTemplate.chk(chkNumber).Left = chkX
frmTemplate.chk(chkNumber).Top = chkY
End Sub

Public Sub SetCheckBoxSize(chkNumber As Byte, sizeX As Integer, sizeY As Integer)
frmTemplate.chk(chkNumber).Width = sizeX
frmTemplate.chk(chkNumber).Height = sizeY
End Sub

Public Sub SetText(ctrlType As String, ctrlNumber As Byte, strText As String)
Select Case ctrlType
Case "btn"
    frmTemplate.btn(ctrlNumber).Caption = strText
Case "txt"
    frmTemplate.txt(ctrlNumber).Text = strText
Case "lbl"
    frmTemplate.lbl(ctrlNumber).Caption = strText
Case "chk"
    frmTemplate.chk(ctrlNumber).Caption = strText
End Select
End Sub

Public Function GetText(txtNumber As Byte) As String
GetText = frmTemplate.txt(txtNumber).Text
End Function

Public Sub SetFocus(ctrlType As String, ctrlNumber As Byte)
Select Case ctrlType
Case "btn"
    frmTemplate.btn(ctrlNumber).SetFocus
Case "txt"
    frmTemplate.txt(ctrlNumber).SetFocus
Case "chk"
    frmTemplate.chk(ctrlNumber).SetFocus
End Select
End Sub

Public Sub LinearGradient(isVirtical As Integer, R1 As Byte, G1 As Byte, B1 As Byte, R2 As Byte, G2 As Byte, B2 As Byte)
frmTemplate.ScaleMode = 1
DrawGradient frmTemplate.hdc, frmTemplate.Width, frmTemplate.Height, RGB(R1, G1, B1), RGB(R2, G2, B2), isVirtical
frmTemplate.Refresh
frmTemplate.ScaleMode = 3
End Sub

Public Sub RadialGradient(X As Long, Y As Long, R As Integer, R1 As Byte, G1 As Byte, B1 As Byte, R2 As Byte, G2 As Byte, B2 As Byte)
frmTemplate.ScaleMode = 1
Radial frmTemplate, R1, G1, B1, R2, G2, B2, X * Screen.TwipsPerPixelX, Y * Screen.TwipsPerPixelY, R
frmTemplate.Refresh
frmTemplate.ScaleMode = 3
End Sub

Public Sub FMsgBox(strMsg As String, Optional msgType As VbMsgBoxStyle = vbInformation, Optional strTitle As String = vbNullString)
MsgBox strMsg, msgType, strTitle
End Sub

Public Function FInputBox(strPrompt As String, strTitle As String, Optional strDefault As String = vbNullString)
FInputBox = InputBox(strPrompt, strTitle, strDefault)
End Function

Private Sub DisableClose(frm As Form, Optional Disable As Boolean = True)
Dim hMenu As Long
Dim nCount As Long
If Disable Then
    hMenu = GetSystemMenu(frm.hwnd, False)
    nCount = GetMenuItemCount(hMenu)
    Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)
    Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)
    DrawMenuBar frm.hwnd
Else
    GetSystemMenu frm.hwnd, True
    DrawMenuBar frm.hwnd
End If
End Sub
